from appium.webdriver.common.appiumby import AppiumBy

from appium_qiyeweixin.page_object.public.nav_menu import NavMenu


class PersonalInformationPage(NavMenu):
    __OPERATION_BTN = (AppiumBy.XPATH, "//*[@text='个人信息']/../../../../..//android.widget.TextView")
    __EDIT_MEMBER = (AppiumBy.XPATH, "//*[@text='编辑成员']")
    __DELETE_MEMBER = (AppiumBy.XPATH, "//*[@text='删除成员']")
    __CONFIRM = (AppiumBy.XPATH, "//*[@text='确定']")

    # 个人信息页
    def __operation(self):
        element = self.do_finds(self.__OPERATION_BTN)[-1]
        element.click()

    # 个人信息操作页
    def __edit_member(self):
        self.do_ele_click(self.__EDIT_MEMBER)

    # 删除成员
    def delete_member(self):
        self.__operation()
        self.__edit_member()
        self.do_ele_click(self.__DELETE_MEMBER)
        self.do_ele_click(self.__CONFIRM)

        from appium_qiyeweixin.page_object.address_book_page import AddressBookPage
        return AddressBookPage(self.driver)

